<?php
/**
 * $Id: uc_note.php 13 2011-08-13 05:19:15Z zyb0807@gmail.com $
 */
if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Uc_note extends CI_Controller {

	//private $_appdir = substr(dirname(__FILE__), 0, -19);
	/**
	 * Index Page for this controller.
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	public function __construct()
	{
		parent::__construct();
		$this->load->model('User_model');
	}

	/**
	 * 测试 ucenter 和 hero 之间的通信
	 */
	public function test()
	{
		exit(API_RETURN_SUCCEED);
	}

	/**
	 * 同步登陆
	 */
	public function synlogin()
	{
		header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
		//var_dump($_ENV);
		if($member = $this->User_model->get_member_by_uid($_ENV['get']['uid']))
		{
			$cookie = array(
				'name' => 'auth',
				'value' => _authcode($_ENV['get']['uid']."\t".$_ENV['get']['username'], 'ENCODE'),
				'expire' => $this->config->item('sess_expiration'),
				'domain' => '.hero.com',
				'path' => '/',
				'prefix' => 'hero_'
			);
			$this->input->set_cookie($cookie);
		}
		else
		{ // 用户在 hero 中不存在

		}
	}

	/**
	 * 同步退出
	 */
	public function synlogout()
	{
		header('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
		$this->session->sess_destroy();
		$cookie = array(
			'name' => 'auth',
			'value' => '',
			'expire' => -3600,
			'domain' => '.hero.com',
			'path' => '/',
			'prefix' => 'hero_'
		);
		$this->input->set_cookie($cookie);
	}

	/**
	 * 更新应用列表
	 */
	public function updateapps()
	{
		file_put_contents('test.txt', BASEPATH);	
	}
}

/* End of file uc_note.php */
/* Location: ./api/app/controllers/uc_note.php */


